from PySide6.QtCore import Qt
from PySide6.QtUiTools import QUiLoader

from TestToolsV2.components.BaseComponent import baseComponent


class showDataDialog(baseComponent):
    """
    活动数据比对详细内容展示框
    """

    # noinspection PyCompatibility
    def __init__(self, windownName, windownUi):
        super().__init__(windownName, windownUi)
        self.__datalog = self.get_windownUi()
        self.__resourceScrollBar = None
        self.__targetScrollBar = None
        self.__initDialog()

    def __initDialog(self):
        self.__datalog.setWindowFlag(Qt.WindowMinMaxButtonsHint)
        self.__resourceScrollBar = self.__datalog.resourceEdit.verticalScrollBar()
        self.__targetScrollBar = self.__datalog.targetEdit.verticalScrollBar()
        self.__resourceScrollBar.valueChanged.connect(self.__scrollBarValueChange)

    def set_resourceEdit_text(self, text=""):
        """
        resourceEdit 追加单行普通文本内容\n
        :param text: 需要追加的文本内容
        """
        self.set_textEdit_text("resourceEdit", text)

    def get_resourceEdit_text(self) -> str:
        """
        获取 resourceEdit 普通文本内容\n
        """
        self.get_textEdit_value("resourceEdit")

    def set_resourceEdit_html(self, html=""):
        """
        resourceEdit 追加单行 Html 文本内容\n
        :param html: 需要追加的文本内容
        """
        self.set_textEdit_html("resourceEdit", html)

    def set_targetEdit_text(self, text=""):
        """
        targetEdit 追加单行普通文本内容\n
        :param text: 需要追加的文本内容
        """
        self.set_textEdit_text("targetEdit", text)

    def get_targetEdit_text(self) -> str:
        """
        获取 targetEdit 普通文本内容\n
        """
        self.get_textEdit_value("targetEdit")

    def set_targetEdit_html(self, html=""):
        """
        targetEdit 追加单行 Html 文本内容\n
        :param html: 需要追加的文本内容
        """
        self.set_textEdit_html("targetEdit", html)

    def __scrollBarValueChange(self, value):
        """
        滑动规划滚动条时，基础表滚动跳跟随滚动
        """
        self.__targetScrollBar.setValue(value)
